from http.client import responses

from a3mall.conftest import login_token,client
import logging

import allure
import pytest
from a3mall.Tools.logger import logger
from a3mall.Tools.tools import ApiClient
from a3mall.utils.load_data import *
from a3mall.Tools.mysql import db


class Test_a3mall():
    # 商品详情
    def test_shop(self,client,login_token):
        token = login_token
        headers = {'auth-token': token}
        responses = client.get(path='/api/goods/view?id=46')
        print(responses.json())
    def test_gwc(self,client,login_token):
        token = login_token
        headers = {'auth-token': token}
        data = {
  "id": 46,
  "sku_id": "",
  "num": 1
}
        responses = client.post(path='/api/cart/add',json_data=data,headers=headers)
        print(responses.json())
    def test_gwcym(self,client,login_token):
        token = login_token
        headers = {'auth-token': token}
        responses = client.get(path='/api/cart?page=1',headers=headers)
        print(responses.json())

    def test_create(self,client,login_token):
        token = login_token
        headers = {'auth-token': token}
        responses = client.get(path='/api/order/confirm?id=580&type=cart&shipping_type=1',headers=headers)
        print(responses.json())

    def test_pay(self,client,login_token):
        token = login_token
        headers = {'auth-token': token}
        data = {
  "id": "580",
  "type": "cart",
  "address_id": 61,
  "store_id": 1,
  "shipping_type": 1,
  "bonus_id": "0",
  "payment": "balance",
  "remarks": "",
  "source": 1,
  "url": "http://10.59.9.12:7001/wap/pages/cart/confirm?id=573&type=cart"
}
        responses = client.post(path='/api/order/create',headers=headers,json_data=data)
        print(responses.json())


if __name__ == '__main__':
    pytest.main()